<%@page import="org.prs.persistence.UserDatabasePersitenceManager"%>
<%@page import="org.prs.model.User"%>
<%@page import="org.apache.commons.validator.GenericValidator"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c-rt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<%@page contentType="text/html"  language="java" %>
<%
    User loggedInUser = (User) session.getAttribute("loggedinuser");

    if (loggedInUser == null) {
        session.setAttribute("loginmsg", "<div id='loginmsg'>Please log in to use services</div>");
        response.sendRedirect("index.jsp");
    }
    int userId = 0;
    UserDatabasePersitenceManager persistUser = new UserDatabasePersitenceManager();
    User user = new User();
    try {
        userId = Integer.parseInt(request.getParameter("userid"));
        user = persistUser.getUserByUserId(userId);
        request.setAttribute("user", user);

    } catch (NumberFormatException e) {
        response.sendRedirect("listUsers.jsp");
    }

%>
<html xmlns="http://www.w3.org/1999/xhtml">

    <head>
        <title>Patnership Registration System | New Child</title>
        <link rel="SHORTCUT ICON" href="images/favicon.ico" />
        <link href="style.css" rel="stylesheet" type="text/css" media="screen" />
        <script type="text/javascript" src="js/menu.js" language="JavaScript">
        </script>
        <script type="text/javascript" src="js/jquery-1.5.1.min.js"></script>
        <script type="text/javascript" src="js/jquery-ui-1.8.10.custom.min.js"></script>
        <link rel="stylesheet" href="css/jquery/jquery-ui-1.8.10.custom.css" type="text/css" />

        <link rel="stylesheet" href="imagedisplay.css" type="text/css"/>
        <script type="text/javascript" src="js/imagegallerylib.js"></script>
        <script type="text/javascript" src="js/child.js"></script>

        <script type="text/javascript">
            $(function() {
                $( ".datefield" ).datepicker({
                    changeMonth: true,
                    changeYear: true
                });
            });


        </script>
    </head>
    <body>
        <div id="wrapper">
            <div id="header">
                <div id="logo">
                    <h1><a href="#">Patnership Record System </a></h1>
                </div>
                <div id="menu">
                    <jsp:include page="includes/header.jsp"></jsp:include>
                    </div>
                </div>
                <!-- end #header -->
                <div id="page">
                    <div id="page-bgtop">
                        <div id="page-bgbtm">
                            <div id="content">
                                <div id ="usersname"><label>${user.firstName} ${user.middleName} ${user.lastName}</label></div>
                            <table width="100%" class="childrenlist">
                                <tr>
                                    <td>
                                        <label>
                                            Username
                                        </label>
                                    </td>
                                    <td>
                                        ${user.firstName}
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <label>
                                            Date Registered
                                        </label>

                                    </td>  
                                    <td>
                                        <fmt:formatDate type="both"  dateStyle="long" timeStyle="long" value="${user.dateRegistered}" />
                                    </td>
                                </tr>
                                <tr>
                                    <td>
                                        <a href="editUser.jsp?userid=${user.userId}">Edit</a>
                                    </td>
                                    <td>
                                        <a href="userupdate/deleteuser?userid=${user.userId}">Delete</a>
                                    </td>
                                </tr>
                            </table>

                        </div>
                    </div>
                    <!-- end #content -->
                    <div id="sidebar">

                        <jsp:include page="includes/userProfile.jsp"></jsp:include>


                        </div>
                        <!-- end #sidebar -->
                        <div style="clear: both;">&nbsp;</div>
                    </div>
                </div>
            </div>
            <!-- end #page -->
        </div>
    <jsp:include page="includes/footer.jsp"></jsp:include>
</body>
</html>
